<template>
    <div>
        <van-address-edit
            :area-list="areaList"
            show-postal
            show-delete
            show-set-default
            show-search-result
            :search-result="searchResult"
            @save="onSave"
            @delete="onDelete"
            @change-detail="onChangeDetail"
        />
    </div>
</template>

<script>
import { apiAddressEdit } from '../../api/index'
export default {
    data() {
        return {
            areaList: {},
            searchResult: []
        }
    },

    methods: {
        onSave() {
            this.$router.push({path: '/address'})
        },
        onDelete() {
            this.$router.push({path: '/address'})
        },
        onChangeDetail(val) {
            if (val) {
                this.searchResult = [{
                name: '黄龙万科中心',
                address: '杭州市西湖区'
            }];
            } else {
                this.searchResult = [];
            }
        }
    },
    mounted() {
        // 获取地址列表
        apiAddressEdit()
        .then(res => {
            this.areaList = res.data.data
        })
        .catch(err => {
            console.log(err);
        })
    }
}
</script>

<style lang="less" scoped>

</style>